/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chanlib;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 *
 * @author robit
 */
public class Chan_IO {
    private static Scanner s = null;
    private static BufferedReader l=null;
    private static PrintWriter o,a = null;
    public final static int OUTFILE=0,ANALFILE=1;
    public static int read()throws IOException{
        InputStreamReader cin = new InputStreamReader(System.in);
        return cin.read();
    }

    // return the number of cases
    public static int initFileIO(String filename) throws IOException{
        s = new Scanner(
                new BufferedReader(new FileReader(filename+".in")));
            //s.useLocale(Locale.US);
        o = new PrintWriter(
                new BufferedWriter(new FileWriter(filename+".out")));
        a = new PrintWriter(
                new BufferedWriter(new FileWriter(filename+".anal")));
        return s.nextInt();
    }
    public static void initIO(String filename) throws IOException{
        s = new Scanner(
                new BufferedReader(new FileReader(filename+".in")));
            //s.useLocale(Locale.US);
        o = new PrintWriter(
                new BufferedWriter(new FileWriter(filename+".out")));
        a = new PrintWriter(
                new BufferedWriter(new FileWriter(filename+".anal")));
        return;
    }
    public static void endIO(){
        s.close();
        o.close();
    }
    public static void writeln(String str, int target){
        switch(target){
            case OUTFILE: o.println(str); break;
            case ANALFILE: a.println(str); break;
        }
    }
    public static String Line(){
        return s.nextLine();
    }
    public static int Int(){
        return s.nextInt();
    }
    public static long Long(){
        return s.nextLong();
    }
    public static String String(){
        return s.next();
    }
    public static void print(String str){
        System.out.print(str);
    }
    public static void print(int str){
        System.out.print(str);
    }
    public static void print(long str){
        System.out.print(str);
    }
    public static void print(double str){
        System.out.print(str);
    }
    public static void println(int str){
        System.out.println(str);
    }
    public static void println(String str){
        System.out.println(str);
    }
    public static void println(long str){
        System.out.println(str);
    }
    public static void println(double str){
        System.out.println(str);
    }
    public static String format(String str,Object ... args){
        return String.format(str, args);
    }
}
